MediaWiki talk:Voice Dictation/voice.js
Proposal I have no idea why optimising half a dozen lines of code is so important, but how about: $( function () { $( 'input' ).each( function () { $( this ).attr( 'x-webkit-speech', 'x-webkit-speech' ); } ); } ); It's easy to read and doesn't create i as a global variable. RE: proposal There are several reasons that would be worse: 1. That would involve using Jquery. This is bad for readability and performance reasons. I am not against Jquery per se, I just am against using it when doing so yields something that has little difference in code size or reliability. 2. It is arguable that your proposed version is actually harder to read. "Let's not talk about this one because it will create an ugly clone of the cobol vs. C style languages debate about readability." 3. This would involve roughly the same amount of actual code, yet have no obvious improvements in code size, functionality, etc. 4. There may be reliability issues with that proposal. Explanation: * One of the browsers supported is IE6+, with Chrome Frame installed. * In the more recent versions of Jquery, several versions of IE are no longer supported, such as IE 6 and 7. "I forgot if 8 is supported." * Since that proposal uses Jquery, if the mediawiki instance of Jquery ever gets upgraded to the latest version, it might break support for several use cases. That being said, if you prefer your version, you are free to make a fork with your version. I will do what I can to share patches. Code Lyoko Wiki: User: Deadcoder 03:33, November 25, 2013 (UTC) :With regards to supported browsers if someone is using ie6 I have serious doubts how much of wikia would work. They rely heavily on jQuery and ceased support for it long ago. This is also a WebKit feature, it's not going to work in any version of ie. :As for performance, you script could load well before the document should be manipulated especially on special pages. Adding the $( function ()... Negates this weakness. The current version also gathers a new nodelist with each iteration, as opposed to the cached version above. I'd be surprised if there was any noticeable difference with such a small script. :I'm far from convinced your native version of the script is better, faster or more suitable for deployment across wikia. Wouldn't this: $( function () { $( 'input' ).attr( 'x-webkit-speech', 'x-webkit-speech' ); } ); Work the same way? In my opinion, jQuery is much more readable than the current code. ~Bobogoobo (talk) 05:35, November 26, 2013 (UTC) :Good point. I seem to have got stuck on iterating through each node for some reason.... Yes, this is uses a Webkit feature. However, I reiterate that we are supporting Google Chrome Frame for Internet Explorer. Additionally, that registers as the latest version of Chrome, which wikia does support. Furthermore, Jquery does support the latest version of Chrome, which is what chrome frame for IE registers as. This is a legitimate not-completely impossible use-case; and I intend to support it. Additionally, given that the current Jquery implementations people have suggested are pretty much the same size as the current non-Jquery version "not counting documentation;" and Jquery is inherently less efficient, using a Jquery implementation of this is equivalent to using a machine gun to kill a squirrel. Again, if anyone wants to make a Jquery-based fork of this, they are free to do so, and I will do what I can to port features and bugfixes to both. BTW, I'm kind of curious. How many users and wikis are actually using this feature? I kind of want to know how far it has spread. Code Lyoko Wiki: User: Deadcoder 15:06, November 26, 2013 (UTC) :There's no way to tell where this is imported. It'd be a nice thing to know, but you tend to only find out when you randomly stumble across it on a wiki or someone reports a bug with it. Bugfix Let it be known that I have fixed the bug. You can now vocally dictate the titles when making new pages. I don't recommend using this. Code Lyoko Wiki: User: Deadcoder 15:48, November 26, 2013 (UTC) :The way you are currently doing this is unreliable because it relies on the time it takes to load the form. Prinplat [w:c:devOpen Source[]] 13:37, November 27, 2013 (UTC) ::I am aware that it is unreliable. I am going to fix the reliability issue in a future version. This was just a "fixed as soon as possible" bugfix. A better version will be available soon. Code Lyoko Wiki: User: Deadcoder 15:29, November 27, 2013 (UTC) Minification It is completely unnecessary to minify such a small script. The only thing it does it destroy the readability of the code. Prinplat [w:c:devOpen Source[]] 13:42, November 27, 2013 (UTC) : Be careful when extending code. I just had to fix the page title dictation fixture. Code Lyoko Wiki: User: Deadcoder 15:51, November 27, 2013 (UTC) ::I modified my last edit to fix it and change the onclick attribute to add an event listener instead. Also never wrap a call back in double quotes as it calls the eval function by default. Prinplat [w:c:devOpen Source[]] 16:34, November 27, 2013 (UTC)